﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;

namespace WinUITest.ViewModels;

public partial class UserViewModel : ObservableObject
{
    public event EventHandler<UserViewModel>? OnDelete;
    [ObservableProperty]
    public partial Guid ID { get; set; } = Guid.NewGuid();
    [ObservableProperty, NotifyPropertyChangedFor(nameof(UserInfo))]
    public partial string Name { get; set; } = string.Empty;
    [ObservableProperty, NotifyPropertyChangedFor(nameof(UserInfo))]
    public partial int Age { get; set; }
    public string UserInfo => $"{Name}-{Age}岁";
    [RelayCommand]
    private void Delete() => OnDelete?.Invoke(this, this);
}
